<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>1111</li>
        <li>2222</li>
    </ul>
    <div id="list">

    </div>
    <script>
        /*
            扩展运算符  ...
            Array.from()    类/伪数组 转 数组   类/伪==》arguments nodeList Set 
            Array.of()      一组值 转为数组
            实例方法：copyWithin()
            实例方法：find()，findIndex()，findLast()，findLastIndex()
            实例方法：fill()
            实例方法：entries()，keys() 和 values()
            实例方法：includes()
            实例方法：flat()
        */

        function a() {
            //类/伪数组 转 数组
            console.log(arguments)
            console.log(Array.from(arguments))
            console.log([...arguments])
            console.log(Array.prototype.slice.call(arguments))
            console.log([].slice.call(arguments))



        }
        a(1, 2, 2, 3, 4, 5, 6, 6)

        // console.log([1,2,3])

        var liDom = document.getElementsByTagName("li");
        console.log(liDom)
        console.log([...liDom])



        console.log(Array.of('a', 'b', 'c'))

// fill 
        var b = new Array(8);
        b.fill(0)
        console.log(b);

        function showBtn() {
            var s = "";
            for (var i = 0; i < b.length; i++) {
                if(b[i] == 1){
                    s += `
                    <button onclick="xuanzuo(${i})" disabled >已选择</button>
                    `
                }else{
                    s += `
                    <button onclick="xuanzuo(${i})" >未选择</button>
                    `
                }
               
            }
            document.getElementById("list").innerHTML = s;
        }
        showBtn();

        function xuanzuo(i) {
            b[i] = 1;
            showBtn()
        }

 //  实例方法：entries()，keys() 和 values()
        var arr=["aa","bb","cc"];
        //               values entries
        for(let v of arr.keys() ){
            console.log(v);
        }

// 循环对象
        var obj={"name":"gao","age":19};

        for( let x in obj ){
            console.log(obj[x])
        }

        console.log( Object.values(obj)) //提取对象中的值组成数组
        console.log( Object.keys(obj)) //提取对象中的key 组成数组

        
        for( let x of Object.values(obj) ){
            console.log(x)
        }


// flat

        var arr2=[22,33,[44,55,[222]]];// [22,33,44,55,222]

        console.log( arr2.flat(Infinity) ) //Infinity无穷大

/*
        var x=[];
        function myFlat(arr2){
            for(var v of arr2){
                if( Array.isArray(v) ){
                    myFlat(v) //diguis
                }else{
                    x.push(v);
                }
            }
        }
        myFlat(arr2);

        console.log(x);
*/

    </script>
</body>

</html>